package com.ucl.web.config;

import com.ucl.common.util.UploadUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class ResourceConfigAdapter extends WebMvcConfigurationSupport {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //获取头像文件的真实路径 work_project代表项目工程名 需要更改
        String path = UploadUtils.getStaticPath()+"avatar\\";
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            registry.addResourceHandler("/avatar/**").
                    addResourceLocations("file:"+path);
        }else{//linux和mac系统 可以根据逻辑再做处理
            registry.addResourceHandler("/avatar/**").
                    addResourceLocations("file:"+path);
        }
        super.addResourceHandlers(registry);
    }
}


